using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Application.Dtos;

namespace ERP.ERPSystem.ProductionSystem.Dto
{
    /// <summary>
    /// 物料需求数据传输对象
    /// </summary>
    public class MaterialRequirementDto : EntityDto<int>
    {
        /// <summary>
        /// 关联的客户订单ID
        /// </summary>
        [Required(ErrorMessage = "客户订单ID不能为空")]
        public int CustomerOrderId { get; set; }

        /// <summary>
        /// 父级需求ID（用于构建层级结构，顶级为0）
        /// </summary>
        public int ParentId { get; set; } = 0;

        /// <summary>
        /// 层级级别（1、2、3...）
        /// </summary>
        [Range(1, 10, ErrorMessage = "层级级别必须在1-10之间")]
        public int Level { get; set; } = 1;

        /// <summary>
        /// 是否为层级标题（true-层级标题，false-具体物料）
        /// </summary>
        public bool IsLevelTitle { get; set; } = false;

        /// <summary>
        /// 层级标题名称（如"第一层"、"第二层"）
        /// </summary>
        public string? LevelTitle { get; set; }

        /// <summary>
        /// 物料编码（关联MaterialproductModel.MaterielCode）
        /// </summary>
        public string? MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string? MaterialName { get; set; }

        /// <summary>
        /// 规格型号
        /// </summary>
        public string? Specifications { get; set; }

        /// <summary>
        /// 需求数量
        /// </summary>
        [Range(0, double.MaxValue, ErrorMessage = "需求数量不能小于0")]
        public decimal RequiredQuantity { get; set; } = 0;

        /// <summary>
        /// 库存数量
        /// </summary>
        [Range(0, double.MaxValue, ErrorMessage = "库存数量不能小于0")]
        public decimal InventoryQuantity { get; set; } = 0;

        /// <summary>
        /// 单位
        /// </summary>
        public string? Unit { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remark { get; set; }

        /// <summary>
        /// 排序序号
        /// </summary>
        public int SortOrder { get; set; } = 0;

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 创建人
        /// </summary>
        public string? CreateUser { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime? UpdateTime { get; set; }

        /// <summary>
        /// 更新人
        /// </summary>
        public string? UpdateUser { get; set; }

        /// <summary>
        /// 是否已删除
        /// </summary>
        public bool IsDeleted { get; set; } = false;
    }

    /// <summary>
    /// 物料需求查询条件DTO
    /// </summary>
    public class MaterialRequirementQueryDto
    {
        /// <summary>
        /// 客户订单ID
        /// </summary>
        public int? CustomerOrderId { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string? MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string? MaterialName { get; set; }

        /// <summary>
        /// 是否为层级标题
        /// </summary>
        public bool? IsLevelTitle { get; set; }

        /// <summary>
        /// 当前页
        /// </summary>
        public int Page { get; set; } = 1;

        /// <summary>
        /// 每页数量
        /// </summary>
        public int Limit { get; set; } = 10;
    }

    /// <summary>
    /// 批量保存物料需求DTO
    /// </summary>
    public class BatchSaveMaterialRequirementDto
    {
        /// <summary>
        /// 客户订单ID
        /// </summary>
        [Required(ErrorMessage = "客户订单ID不能为空")]
        public int CustomerOrderId { get; set; }

        /// <summary>
        /// 物料需求列表
        /// </summary>
        public List<MaterialRequirementDto> MaterialRequirements { get; set; } = new List<MaterialRequirementDto>();
    }
} 